var tests = ["test_user_shouldHavePermission",
             "test_user_shouldHaveDiscount"];


var test_user_shouldHavePermission = function() {
    // User with Permission
	var pgHasPermission = new PermissionGroup("HasPermissionGroup");
    var can_access = new Permission("can_access_test");
    pgHasPermission.authorizations.add(new Authorization(can_access));

    var userWithPermission = new User("dummyadmin", "dummy", "Dummy", "User", "", "", false, true, null, pgHasPermission);

    assertEqual(true,  userWithPermission.hasPermission("can_access_test"));
    assertEqual(false, userWithPermission.hasPermission("can_access_all"));
};

var test_user_shouldHaveDiscount = function() {
    // New Club
    var club = new Club("TC TestXXX", "testtestXXX", null, 1, "Europe/Vienna", true, 1440, 1440, true);

    // User with Usergroups
	var usergroup1 = new UserGroup("UGP1", "", 0.3);
	club.usergroups.add(usergroup1);
	var usergroup2 = new UserGroup("UGP2", "", 0.1);
	club.usergroups.add(usergroup2);

	var userWithTwoUsergroups = new User("user2gp", "dummy", "Dummy", "User", "", "", false, true, null, null);
    club.users.add(userWithTwoUsergroups);

    var userWithOneUsergroup = new User("user1gp", "dummy", "Dummy", "User", "", "", false, true, null, null);
    club.users.add(userWithOneUsergroup);

    var userWithNoUsergroup = new User("user0gp", "dummy", "Dummy", "User", "", "", false, true, null, null);
    club.users.add(userWithNoUsergroup);

    userWithTwoUsergroups.addUserGroupMembership(usergroup1);
    userWithTwoUsergroups.addUserGroupMembership(usergroup2);

    userWithOneUsergroup.addUserGroupMembership(usergroup2);

    assertEqual(0.3, userWithTwoUsergroups.getDiscount());
    assertNotEqual(0.1, userWithTwoUsergroups.getDiscount());
    assertNotEqual(0.0, userWithTwoUsergroups.getDiscount());
    
    assertEqual(0.1, userWithOneUsergroup.getDiscount());
    assertNotEqual(0.3, userWithOneUsergroup.getDiscount());
    assertNotEqual(0.0, userWithOneUsergroup.getDiscount());
    
    assertEqual(0.0, userWithNoUsergroup.getDiscount());
    assertNotEqual(0.3, userWithNoUsergroup.getDiscount());
    assertNotEqual(0.1, userWithNoUsergroup.getDiscount());
};